package com.arcsoft.crud.test;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;


public class Configer {
	private static final Map<String, String> configMap = new HashMap<String, String>();

	@SuppressWarnings("unused")
	public static void load(String path) {
		Properties props = new Properties();
		try {
			InputStream in = new BufferedInputStream(new FileInputStream(path));
			props.load(in);
			@SuppressWarnings("rawtypes")
			Enumeration en = props.propertyNames();
			while (en.hasMoreElements()) {
	              String key = (String) en.nextElement();
				  String Property = props.getProperty (key);
	              configMap.put(key, props.getProperty (key));
	        }
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static String getValueString(String name) {
		return configMap.get(name).trim();
	}

	public static boolean getValueBoolean(String name) {
		return configMap.get(name) == null ? false : Boolean.valueOf(configMap.get(name));
	}

	public static int getValueInt(String name) {
		return configMap.get(name) == null ? 0 : Integer.valueOf(configMap.get(name));
	}

}
